package Server;
/*comment about file*/
import java.util.*;

/**
 * @author David
 * @version $Revision: 1.0 $
 */
public class AppointmentBook{
	/**
	 * Field apptBook.
	 */
	private static ArrayList<DailyAppointment> apptBook;
	
	/**
	 * Constructor for AppointmentBook.
	 */
	public AppointmentBook(){
		setApptBook(new ArrayList<DailyAppointment>());
	}
	
	/**
	 * Method toString.
	
	 * @return String */
	public String toString(){
		final String str = "";
		return str;
	}
	
	/**
	 * Adds an appointment to the AppointmentBook ArrayList
	 * Checks to see if a DailyAppointment exists for the day and adds to day if exists
	 * If not, creates a new DailyAppointment object and adds to that
	 * @param appointment
	 * @return boolean */
	public static boolean canAddAppt(Appointments appointment){
		if(getApptBook().isEmpty()){
			final DailyAppointment da = new DailyAppointment(appointment.getDay());
			da.canAddAppt(appointment);
			getApptBook().add(da);
			return true;
		}
		for(DailyAppointment appt : getApptBook()){
			if(appt.getDay() == appointment.getDay())
				return(appt.canAddAppt(appointment));
			
		}
		return false;
		
	}
	
	/**
	 * Method canRemoveAppt.
	 * @param appointment Appointments
	
	 * @return boolean */
	public static boolean canRemoveAppt(Appointments appointment){
		boolean remove = false;
		if(getApptBook().isEmpty())
			return false;
		for(DailyAppointment da : getApptBook()){
			remove = da.canRemoveAppt(appointment);
			if(remove)
				return true;
		}
		return remove;
	}
	
	/**
	 * Method getApptBook.
	
	 * @return ArrayList<DailyAppointment> */
	public static ArrayList<DailyAppointment> getApptBook(){
		return apptBook;
	}

	/**
	 * Method setApptBook.
	 * @param apptBook ArrayList<DailyAppointment>
	 */
	public static void setApptBook(ArrayList<DailyAppointment> apptBook) {
		AppointmentBook.apptBook = apptBook;
	}
}
